import {UserActions} from './user';

const initialState = {
  password: '',
  role: {
    perms: [],
  },
};

export const AccountDetailActions = {
  ACCOUNT_DETAIL_UPDATE: 'account_detail_update',
};

export function updateAccountDetail(payload) {
  return {
    type: AccountDetailActions.ACCOUNT_DETAIL_UPDATE,
    payload,
  };
}

export default function accountDetail(state = initialState, action) {
  switch (action.type) {
    case AccountDetailActions.ACCOUNT_DETAIL_UPDATE:
      return {...state, ...action.payload};
    case UserActions.USER_SIGN_OUT:
      return {};
    default:
      return state;
  }
}
